#ifndef __THREAD_POOL_H__
#define __THREAD_POOL_H__

/* 线程池 */
#include <my_header.h>
#include "task_queue.h"
#include "dbconn_pool.h"


// 线程共享资源
typedef struct sharedRes_s {
    dbConnPool_t dbconnectPool;
    taskQueue_t taskQueue;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
    int exitFlag; // 线程池退出标志
} sharedRes_t;

// 线程池
typedef struct threadPool_s {
    int threadnum;
    pthread_t *tidArr;
} threadPool_t;

int shared_res_init(sharedRes_t *sharedRes, int workernum);
int thread_pool_init(threadPool_t *pThreadPool, int workernum);
int make_worker(sharedRes_t *pSharedRes, threadPool_t *pThreadPool);

#endif
